package com.xtedu.examproject.service;

import com.xtedu.examproject.dao.base.ExaminationDao;
import com.xtedu.examproject.dao.impl.ExaminationDaoImpl;
import com.xtedu.examproject.entity.Examination;

import java.util.List;

public class ExaminationService {
    private ExaminationDao examinationDao;
    public ExaminationService() {
        examinationDao = new ExaminationDaoImpl();
    }

    public int insertExamination(Examination examination) throws Exception {
        return examinationDao.insert(examination);
    }

    public int deleteExamination(Examination examination) throws Exception {
        return examinationDao.delete(examination);
    }

    public int updateExamination(Examination examination) throws Exception {
        return examinationDao.update(examination);
    }

    public Examination getExaminationById(int examinationId) throws Exception {
        return examinationDao.findById(examinationId);
    }

    public List<Examination> getAllExamination() throws Exception {
        return examinationDao.findAll();
    }
    public List<Examination> getExaminationByCourseId(int courseId) throws Exception {
        return examinationDao.findExaminationByCourseId(courseId);
    }

    public int findCourseIdByExamId(int examId) {
        return examinationDao.findCourseIdByExamId(examId);
    }
}
